dict1 = {'name': 'Tom', 'age': 20, "sex": '男'}
# # 字典是可变数据类型
# print(dict1)
# print(type(dict1))
# """
# 注意:
# 字典的key 只可以是不可变数据类型, 而且不可以重复,重复会覆盖
# 字典的value, 可以是所有的数据类型
# """
# # 新增/修改
dict1["Country"] = "丑国"
print(dict1)
# dict1["name"] = "汤姆"
# print(dict1)
# # 删除相关语法
# # 删除整个字典
# # del dict1
# # print(dict1)
# # # 删除某个键值对:根据key进行删除的,要删除的key如果不存在则报错
# # del  dict1["sex"]
# # print(dict1)
# # 清空字典
# dict1.clear()
# print(dict1)
# # 查找相关语法
# # dict1 = {'name': 'Tom', 'age': 20, "sex": '男'}
# # # 直接根据key查找value:找不到则报错
# # print(dict1["name"])
# # # print(dict1["name1"])
# # # 根据key查找value: 字典.get(key) 如果找不到不报错,返回默认值
# # print(dict1.get("age"))
# # print(dict1.get("age1","未找到"))


# ===============================================
dict1 = {'name': 'Tom', 'age': 20, "sex": '男'}

# 获取字典内的所有的key
res1 = dict1.keys()
print(list(res1))
# 获取字典内的所有的value
res2 = dict1.values()
print(res2)
# 获取字典内的所有的键值对
res3 = dict1.items()
print(res3)

for k in dict1.keys():
    print(k)

for v in dict1.values():
    print(v)

for item in dict1.items():
    print(item)

for k,v in dict1.items():
    print(f"当前的值是:{v},键是:{k}")
